import { http } from '@/apis/http';
import { ApiResponse } from '@/apis/types/Response';
import { Posts } from '@/apis/types/Posts';

export const postsApi = {
	getPosts(pageNum: number, pageSize: number, isTop: number) {
		return http.get<ApiResponse<Posts[]>>('/content/posts/getList', {
			params: {
				pageNum: pageNum || 1,
				pageSize: pageSize || 10,
				isTop: isTop,
			},
		});
	},
	addPosts(post: Posts) {
		return http.post<ApiResponse<Posts>>(`/content/posts/add`, post);
	},
	updatePosts(post: Posts) {
		return http.post<ApiResponse<Posts>>(`/content/posts/update`, post);
	},
	deletePosts(id: number) {
		return http.post<ApiResponse<Posts>>(`/content/posts/delete/${id}`);
	},
};
